package part2eightlock;

// 先执行sendEmail方法
public class Lock801 {

    public static void main(String[] args) throws InterruptedException {
        Phone01 phone = new Phone01();

        new Thread(() -> {
            try {
                phone.sendEmail();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "A").start();

        Thread.sleep(200);

        new Thread(() -> {
            try {
                phone.sendSMS();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "B").start();
    }

}


class Phone01 {

    public synchronized void sendEmail() throws Exception {
        System.out.println("sendEmail");
    }

    public synchronized void sendSMS() throws Exception {
        System.out.println("sendSMS");
    }

}